package org.tech4j.logging.common.entity;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;
import java.util.Objects;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/5 20:20
 **/
public class LogDetail {

    /**
     * 链路追踪id
     */
    private String traceId;

    /**
     * 用户id
     */
    private String userId;

    /**
     * 操作人
     */
    private String operator;

    /**
     * 租户id
     */
    private String tenantId;

    /**
     * 操作业务模块
     */
    private String moduleType;

    /**
     * 操作业务模块名称
     */
    private String moduleName;

    /**
     * 操作名
     */
    private String name;

    /**
     * 操作明细
     */
    private String content;

    /**
     * 拓展字段
     */
    private Map<String, String> ext;

    /**
     * 请求方法名
     */
    private String requestMethod;

    /**
     * 请求地址
     */
    private String requestUrl;

    /**
     * 用户 IP
     */
    private String userIp;

    /**
     * 浏览器 UserAgent
     */
    private String userAgent;

    /**
     * Java 方法名
     */
    private String javaMethod;

    /**
     * Java 方法的参数
     */
    private String javaMethodArgs;

    /**
     * 开始时间
     */
    private LocalDateTime startTime;

    /**
     * 执行时长，单位：毫秒
     */
    private Long duration;

    /**
     * 结果数据
     */
    private String resultData;

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getModuleType() {
        return moduleType;
    }

    public void setModuleType(String moduleType) {
        this.moduleType = moduleType;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Map<String, String> getExt() {
        return ext;
    }

    public void setExt(Map<String, String> ext) {
        this.ext = ext;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getRequestUrl() {
        return requestUrl;
    }

    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl;
    }

    public String getUserIp() {
        return userIp;
    }

    public void setUserIp(String userIp) {
        this.userIp = userIp;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getJavaMethod() {
        return javaMethod;
    }

    public void setJavaMethod(String javaMethod) {
        this.javaMethod = javaMethod;
    }

    public String getJavaMethodArgs() {
        return javaMethodArgs;
    }

    public void setJavaMethodArgs(String javaMethodArgs) {
        this.javaMethodArgs = javaMethodArgs;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }

    public String getResultData() {
        return resultData;
    }

    public void setResultData(String resultData) {
        this.resultData = resultData;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LogDetail logDetail = (LogDetail) o;
        return Objects.equals(traceId, logDetail.traceId) && Objects.equals(userId, logDetail.userId) && Objects.equals(operator, logDetail.operator) && Objects.equals(tenantId, logDetail.tenantId) && Objects.equals(moduleType, logDetail.moduleType) && Objects.equals(moduleName, logDetail.moduleName) && Objects.equals(name, logDetail.name) && Objects.equals(content, logDetail.content) && Objects.equals(ext, logDetail.ext) && Objects.equals(requestMethod, logDetail.requestMethod) && Objects.equals(requestUrl, logDetail.requestUrl) && Objects.equals(userIp, logDetail.userIp) && Objects.equals(userAgent, logDetail.userAgent) && Objects.equals(javaMethod, logDetail.javaMethod) && Objects.equals(javaMethodArgs, logDetail.javaMethodArgs) && Objects.equals(startTime, logDetail.startTime) && Objects.equals(duration, logDetail.duration) && Objects.equals(resultData, logDetail.resultData);
    }

    @Override
    public int hashCode() {
        return Objects.hash(traceId, userId, operator, tenantId, moduleType, moduleName, name, content, ext, requestMethod, requestUrl, userIp, userAgent, javaMethod, javaMethodArgs, startTime, duration, resultData);
    }

    @Override
    public String toString() {
        return "LogDetail{" +
                "traceId='" + traceId + '\'' +
                ", userId=" + userId +
                ", operator='" + operator + '\'' +
                ", tenantId=" + tenantId +
                ", moduleType='" + moduleType + '\'' +
                ", moduleName='" + moduleName + '\'' +
                ", name='" + name + '\'' +
                ", content='" + content + '\'' +
                ", ext=" + ext +
                ", requestMethod='" + requestMethod + '\'' +
                ", requestUrl='" + requestUrl + '\'' +
                ", userIp='" + userIp + '\'' +
                ", userAgent='" + userAgent + '\'' +
                ", javaMethod='" + javaMethod + '\'' +
                ", javaMethodArgs='" + javaMethodArgs + '\'' +
                ", startTime=" + startTime +
                ", duration=" + duration +
                ", resultData='" + resultData + '\'' +
                '}';
    }
}
